package cn.hxzy.course.service.impl;

import cn.hxzy.common.domain.Course;
import cn.hxzy.common.domain.Professional;
import cn.hxzy.course.mapper.ProfessionalMapper;
import cn.hxzy.course.service.CourseService;
import cn.hxzy.course.service.ProfessionalService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author niuyi
 * @since 2024-06-22
 */
@Service
public class ProfessionalServiceImpl extends ServiceImpl<ProfessionalMapper, Professional> implements ProfessionalService {
    @Autowired
    private ProfessionalMapper professionalMapper;

    @Autowired
    private CourseService courseService;

    @Override
    public List<Professional> selectAll(Integer schoolId) {
        return professionalMapper.selectList(new QueryWrapper<Professional>()
                .eq("school_id",schoolId)
        );
    }

    //根据课程Id查专业
    @Override
    public String selectProfessionalName(Integer courseId) {
        Course courseById = courseService.getCourseById(courseId);
        Professional professional = professionalMapper.selectById(courseById.getProfessionalId());
        return professional.getProfessionalName();
    }
}
